Leadtools.ImageProcessing.Core Namespace > WindowLevelExtCommand Class > WindowLevelExtCommand Constructor : WindowLevelExtCommand Constructor(Int32,Int32,RasterColor16[],RasterByteOrder) |
public WindowLevelExtCommand( int lowBit, int highBit, RasterColor16[] lookupTable, RasterByteOrder order )
'Declaration Public Function New( _ ByVal lowBit As Integer, _ ByVal highBit As Integer, _ ByVal lookupTable() As RasterColor16, _ ByVal order As RasterByteOrder _ )
'Usage Dim lowBit As Integer Dim highBit As Integer Dim lookupTable() As RasterColor16 Dim order As RasterByteOrder Dim instance As New WindowLevelExtCommand(lowBit, highBit, lookupTable, order)
public WindowLevelExtCommand( int lowBit, int highBit, RasterColor16[] lookupTable, RasterByteOrder order )
function WindowLevelExtCommand( lowBit , highBit , lookupTable , order )
public: WindowLevelExtCommand( int lowBit, int highBit, array<RasterColor16>^ lookupTable, RasterByteOrder order )
Public Sub WindowLevelExtConstructorExample() Dim codecs As New RasterCodecs() codecs.ThrowExceptionsOnInvalidImages = True Dim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg")) ' Prepare the command 'Change the image to 16-bit grayscale Dim graycommand As GrayscaleCommand = New GrayscaleCommand(16) graycommand.Run(leadImage) Dim MinMaxBits As MinMaxBitsCommand = New MinMaxBitsCommand MinMaxBits.Run(leadImage) Dim MinMaxValues As MinMaxValuesCommand = New MinMaxValuesCommand MinMaxValues.Run(leadImage) Dim Size As Integer = (1 << (MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1)) Dim LookupTable() As RasterColor16 ReDim LookupTable(Size - 1) ' fill the first half of the LookupTable with RED. Dim x As Integer For x = 0 To (Size \ 2 - 1) LookupTable(x) = New RasterColor16(RasterColor16.MaximumComponent, 0, 0) Next ' fill the rest with gray values. For x = Size \ 2 To Size - 1 Dim y As Integer = CType((x) * RasterColor16.MaximumComponent / (Size), Integer) LookupTable(x) = New RasterColor16(y, y, y) Next Dim command As WindowLevelExtCommand = New WindowLevelExtCommand(MinMaxBits.MinimumBit, MinMaxBits.MaximumBit, LookupTable, RasterByteOrder.Bgr) command.Run(leadImage) End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class
public void WindowLevelExtConstructorExample() { // Load an image RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image2.dcm")); // Prepare the command MinMaxBitsCommand MinMaxBits = new MinMaxBitsCommand(); MinMaxBits.Run(image); MinMaxValuesCommand MinMaxValues = new MinMaxValuesCommand(); MinMaxValues.Run(image); int Size = (1 <<(MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1)); RasterColor16 [] LookupTable = new RasterColor16[Size]; // fill the first half of the LookupTable with RED. for(int x = 0; x < Size / 2; x++) LookupTable[x] = new RasterColor16(RasterColor16.MaximumComponent, 0, 0); // fill the rest with gray values. for(int x = Size / 2; x < Size; x++) { int y = (UInt16)((x - MinMaxValues.MinimumValue) * RasterColor16.MaximumComponent / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue)); LookupTable[x] = new RasterColor16(y, y, y); } WindowLevelExtCommand command = new WindowLevelExtCommand(MinMaxBits.MinimumBit, MinMaxBits.MaximumBit, LookupTable, RasterByteOrder.Bgr); command.Run(image); } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }
function WindowLevelExtConstructorExample() { var codecs = new Leadtools.Codecs.RasterCodecs(); codecs.throwExceptionsOnInvalidImages = true; // Load the image var srcFileName = "Assets\\Image2.dcm"; var processedImage; return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) { return codecs.loadAsync(Leadtools.LeadStreamFactory.create(loadFile)); }).then(function (image) { // Prepare the command with (Leadtools.ImageProcessing.Core) { var MinMaxBits = new MinMaxBitsCommand(); MinMaxBits.run(image); var MinMaxValues = new MinMaxValuesCommand(); MinMaxValues.run(image); var Size = (1 << (MinMaxBits.maximumBit - MinMaxBits.minimumBit + 1)); var LookupTable = new Array(); // fill the first half of the LookupTable with RED. for (var x = 0; x < Size / 2; x++) LookupTable[x] = Leadtools.RasterColor16Helper.create(Leadtools.RasterColor16Helper.maximumComponent, 0, 0); // fill the rest with gray values. for (var x = Size / 2; x < Size; x++) { var y = (x - MinMaxValues.minimumValue) * Leadtools.RasterColor16Helper.maximumComponent / (MinMaxValues.maximumValue - MinMaxValues.minimumValue); LookupTable[x] = Leadtools.RasterColor16Helper.create(y, y, y); } var command = new WindowLevelExtCommand(MinMaxBits.minimumBit, MinMaxBits.maximumBit, LookupTable, Leadtools.RasterByteOrder.bgr); command.run(image); } }); }
[TestMethod] public async Task WindowLevelExtConstructorExample() { // Load an image RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; // Load the image string srcFileName = @"Assets\Image2.dcm"; StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName); RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile)); // Prepare the command MinMaxBitsCommand MinMaxBits = new MinMaxBitsCommand(); MinMaxBits.Run(image); MinMaxValuesCommand MinMaxValues = new MinMaxValuesCommand(); MinMaxValues.Run(image); int Size = (1 <<(MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1)); RasterColor16 [] LookupTable = new RasterColor16[Size]; // fill the first half of the LookupTable with RED. for(int x = 0; x < Size / 2; x++) LookupTable[x] = RasterColor16Helper.Create(RasterColor16Helper.MaximumComponent, 0, 0); // fill the rest with gray values. for(int x = Size / 2; x < Size; x++) { int y = (UInt16)((x - MinMaxValues.MinimumValue) * RasterColor16Helper.MaximumComponent / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue)); LookupTable[x] = RasterColor16Helper.Create(y, y, y); } WindowLevelExtCommand command = new WindowLevelExtCommand(MinMaxBits.MinimumBit, MinMaxBits.MaximumBit, LookupTable, RasterByteOrder.Bgr); command.Run(image); }
public void WindowLevelExtConstructorExample(RasterImage image, Stream outStream) { // Prepare the command MinMaxBitsCommand MinMaxBits = new MinMaxBitsCommand(); MinMaxBits.Run(image); MinMaxValuesCommand MinMaxValues = new MinMaxValuesCommand(); MinMaxValues.Run(image); int Size = (1 << (MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1)); RasterColor16[] LookupTable = new RasterColor16[Size]; // fill the first half of the LookupTable with RED. for (int x = 0; x < Size / 2; x++) LookupTable[x] = new RasterColor16(RasterColor16.MaximumComponent, 0, 0); // fill the rest with gray values. for (int x = Size / 2; x < Size; x++) { int y = (UInt16)((x - MinMaxValues.MinimumValue) * RasterColor16.MaximumComponent / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue)); LookupTable[x] = new RasterColor16(y, y, y); } WindowLevelExtCommand command = new WindowLevelExtCommand(MinMaxBits.MinimumBit, MinMaxBits.MaximumBit, LookupTable, RasterByteOrder.Bgr); command.Run(image); // Save result image RasterCodecs codecs = new RasterCodecs(); codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24); image.Dispose(); }
Public Sub WindowLevelExtConstructorExample(ByVal image As RasterImage, ByVal outStream As Stream)
' Prepare the command
Dim MinMaxBits As MinMaxBitsCommand = New MinMaxBitsCommand()
MinMaxBits.Run(image)
Dim MinMaxValues As MinMaxValuesCommand = New MinMaxValuesCommand()
MinMaxValues.Run(image)
Dim Size As Integer = (1 << (MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1))
Dim LookupTable As RasterColor16() = New RasterColor16(Size - 1){}
' fill the first half of the LookupTable with RED.
Dim x As Integer = 0
Do While x < Size / 2
LookupTable(x) = New RasterColor16(RasterColor16.MaximumComponent, 0, 0)
x += 1
Loop
' fill the rest with gray values.
x = Size / 2
Do While x < Size
Dim y As Integer = CUShort((x - MinMaxValues.MinimumValue) * RasterColor16.MaximumComponent / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue))
LookupTable(x) = New RasterColor16(y, y, y)
x += 1
Loop
Dim command As WindowLevelExtCommand = New WindowLevelExtCommand(MinMaxBits.MinimumBit, MinMaxBits.MaximumBit, LookupTable, RasterByteOrder.Bgr)
command.Run(image)
' Save result image
Dim codecs As RasterCodecs = New RasterCodecs()
codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24)
image.Dispose()
End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2